if (isMultiplayer) then {titleText ["", "BLACK FADED", 0.1]};

if (isNil "paramsArray") then {
	if (isClass (missionConfigFile/"Params")) then {
		for "_i" from 0 to (count (missionConfigFile/"Params") - 1) do {
			_paramName = configName ((missionConfigFile >> "Params") select _i);
			__mNsSetVar [_paramName, getNumber (missionConfigFile >> "Params" >> _paramName >> "default")];
		};
	};
} else {
	for "_i" from 0 to (count paramsArray - 1) do {
		__mNsSetVar [configName ((missionConfigFile >> "Params") select _i), paramsArray select _i];
	};
};

d_WithMHQTeleport = switch (d_WithMHQTeleport) do {case 0: {true};case 1: {false};};
d_FastTime = switch (d_FastTime) do {case 0: {true};case 1: {false};};
d_LockArmored = if (d_LockArmored == 1) then {false} else {true};
d_LockCars = if (d_LockCars == 1) then {false} else {true};
d_LockAir = if (d_LockAir == 1) then {false} else {true};
WithRepStations = if (WithRepStations == 1) then {false} else {true};
#ifndef __TT__
WithJumpFlags = if (WithJumpFlags == 1) then {false} else {true};
#else
WithJumpFlags = false;
d_MaxNumAmmoboxes = d_MaxNumAmmoboxes * 2;
#endif
ParaAtBase = if (ParaAtBase == 1) then {false} else {true};
AmmoBoxHandling = if (AmmoBoxHandling == 0) then {false} else {true};
WithBackpack = if (WithBackpack == 1) then {false} else {true};
LimitedWeapons = if (LimitedWeapons == 1) then {false} else {true};
WithChopHud = if (WithChopHud == 1) then {false} else {true};
#ifndef __RANKED__
d_with_ranked = if (d_with_ranked == 1) then {false} else {true};
#else
d_with_ranked = true;
#endif

d_reload_engineoff = if (d_reload_engineoff == 1) then {false} else {true};

d_p_marker_dirs = if (d_p_marker_dirs == 1) then {false} else {true};
d_v_marker_dirs = if (d_v_marker_dirs == 1) then {false} else {true};

d_with_mgnest = if (d_with_mgnest == 1) then {false} else {true};

#ifdef __ACE__
// override for ACE. ACE 2 has it's own backpack/ruck feature
WithBackpack = false;
#endif

d_with_ai =
#ifdef __AI__
	true;
#else
	false;
#endif

setViewDistance d_InitialViewDistance;

// this will remove setVehicleInits in BIS effects and should fix sky in fire bug
// probably breaks addons like WarFX, dunno, I'm not using it
#ifndef __ACE__
if (OverrideBISEffects == 0) then {
	[] spawn {
		sleep 0.1;
		waitUntil {!isNil "BIS_Effects_Secondaries"};
		__cppfln(BIS_Effects_EH_Killed,BIS_Effects\killed.sqf);
		__cppfln(BIS_Effects_AirDestruction,BIS_Effects\airdestruction.sqf);
		__cppfln(BIS_Effects_AirDestructionStage2,BIS_Effects\airdestructionstage2.sqf);
		__cppfln(BIS_Effects_Burn,BIS_Effects\burn.sqf);
	};
};
#endif

d_number_targets_h = d_MainTargets;

if (d_MainTargets >= 50) then {
	_h = switch (d_MainTargets) do {
		case 50: {7};
		case 60: {5};
		case 70: {8};
		case 90: {29};
	};
	d_MainTargets = _h;
};

if (d_GrasAtStart == 1) then {setterraingrid 50};

// WEST, EAST or GUER for own side, setup in x_setup.sqf
#ifdef __OWN_SIDE_WEST__
d_own_side = "WEST";
d_enemy_side = "EAST";
#endif
#ifdef __OWN_SIDE_EAST__
d_own_side = "EAST";
d_enemy_side = "WEST";
#endif
#ifdef __OWN_SIDE_GUER__
d_own_side = "GUER";
d_enemy_side = "EAST";
#endif
#ifdef __TT__
d_enemy_side = "GUER";
d_own_side = "WEST";
#endif

// setup in x_setup.sqf
d_version = [];
#define __adddv(dtype) d_version set [count d_version, #dtype]
if (d_with_ai) then {__adddv(AI)};
#ifdef __REVIVE__
__adddv(REVIVE);
#endif
#ifdef __TT__
__adddv(TT);
#endif
#ifdef __ACE__
__adddv(ACE);
#endif
#ifdef __WOUNDS__
__adddv(WOUNDS);
#endif
if (d_with_ranked) then {__adddv(RANKED)};

#ifdef __DEFAULT__
d_target_names = [
	[[3126.2168,3875.3857,0],"Djolan",175], // 0
	[[4534.5611,6671.9194,0],"Bolabongo",500], // 1
	[[5796.8667,6209.4072,0],"Molatia Airport",400], // 2
	[[2099.2957,5774.8872,0],"Kwako",150], // 3
	[[5972.2607,3316.5132,0],"Mawimbela",200], // 4
	[[6133.2393,1273.3252,0],"Kingala",150], // 5
	[[7520.3359,3175.2813,0],"Ursana",150], // 6
	[[8488.8623,3251.4136,0],"Kirabo",175], // 7
	[[8248.5977,5531.5107,0],"Canto",300], // 8
	[[3014.5032,7041.7939,0],"Swonto",200], // 9
	[[7069.2949,8514.6367,0],"Xibo",150], // 10
	[[5124.7559,5138.5488,0],"Nubak",300], // 11
	[[4620.6655,8060.6353,0],"Engor",250], // 12
	[[5830.7788,8135.3022,0],"Casinda",100], // 13
	[[6835.2451,7594.9629,0],"Maluri",250], // 14
    [[1318.2162,4290.7827,0],"Simbala",150], // 15
    [[6509.1182,7876.6626,0],"Hill 96",150], // 16
    [[1374.9391,683.91541,0],"Ramons Plantation",150], // 17
    [[1715.3533,1358.0127,0],"Camara",250], // 18
    [[2536.8257,1774.2761,0],"Cainna Wind",300], // 19
    [[6673.8667,4211.7861,0],"Cova",150], // 20
    [[6465.7271,5024.5889,0],"Camp Sova",150], // 21
    [[612.57635,7201.6655,0],"Minesini",200], // 22
    [[2190.3379,6977.2969,0],"Isla Caspal",150], // 23
    [[1260.6926,6619.124,0],"Forteza",200], // 24
    [[7442.7861,1605.2852,0],"Camp Kimbaka",150], // 25
    [[7182.4819,2290.5078,0],"Tasmera Airport",250], // 26
    [[5148.7402,3744.0735,0],"West Mawimbela",250], // 27
    [[8326.2607,7503.2319,0],"Ruins of Dasha",150], // 28
    [[1117.5004,7853.1465,0],"Isla Hazena",450] // 29

];
#endif
#ifdef __TT__
d_target_names = [
	[[2733.7,5306.05,0],"Zelenogorsk",300], // 0
	[[6728.4,2590.29,0],"Chernogorsk",300], // 1
	[[10269.5,2110.25,0],"Elektrozavodsk",300], // 2
	[[12012.4,9095.97,0],"Berezino",300], // 3
	[[6147.54,7757.34,0],"Stary Sobor",300], // 4
	[[3814.73,8901.37,0],"Vybor",300], // 5
	[[7555.26,5149.45,0],"Mogilevka",300], // 6
	[[10680.4,8054.11,0],"Polana",300], // 7
	[[10412.8,9768.09,0],"Dubrovka",300], // 8
	[[9548.47,8846.42,0],"Gorka",300], // 9
	[[13381.5,6254.74,0],"Solnichniy",300], // 10
	[[10118.6,5521.33,0],"Staroye",300], // 11
	[[1697.54,3847.5,0],"Pavlovo",300], // 12
	[[3075.33,7916.48,0],"Pustoschka",300], // 13
	[[12971.1,10109.1,0],"Berezino Harbour",300], // 14
	[[9178.31,3870.64,0],"Pusta",300], // 15
	[[4741.96,6799.19,0],"Rogovo",300], // 16
	[[4393.77,4606.03,0],"Kozlovka",300], // 17
	[[1828.09,2249.49,0],"Kamenka",300], // 18
	[[8659.28,11840.9,0],"Gvozdno",300] // 19
];
#endif
#ifdef __EVERON__
d_target_names = [
	[[4671.13,10722.6,0],"Saint Phillipe",300], // 0
	[[4527.21,9506.97,0],"Meaux",300], // 1
	[[4941.61,9077.45,0],"Tyrone",300], // 2
	[[4135.95,7801.06,0],"Gravette",300], // 3
	[[4897.7,6973.78,0],"Montignac",300], // 4
	[[5755.12,7052.86,0],"Entre Deux",300], // 5
	[[1268.59,5967.68,0],"Lamentin",300], // 6
	[[2591.19,5442.5,0],"Le Moule",300], // 7
	[[5052.18,3980.89,0],"Morton",300], // 8
	[[5297.28,5360.35,0],"Figari",300], // 9
	[[5510.28,6084.46,0],"Provins",300], // 10
	[[7078.44,6039.96,0],"Chotain",300], // 11
	[[7567.68,5573.83,0],"Laruns",300], // 12
	[[7554.94,4724.12,0],"Levie",300], // 13
	[[7183.02,2293.89,0],"Regina",300], // 14
	[[8830.23,2717.55,0],"Durras",300], // 15
	[[9114.86,2174.21,0],"Vernon",300], // 16
	[[9654.58,1565.62,0],"Saint Pierre",300] // 17
];
#endif

#ifdef __DEBUG__
// only for debugging, creates markers at all main target positions
{
	_pos = _x select 0;
	_name = _x select 1;
	_size = _x select 2;
	_marker= createMarkerLocal [_name, _pos];
	_marker setMarkerShapeLocal "ELLIPSE";
	_name setMarkerColorLocal "ColorGreen";
	_name setMarkerSizeLocal [_size,_size];
	_name = _name + "xx";
	_marker= createMarkerLocal [_name, _pos];
	_marker setMarkerTypeLocal "mil_dot";
	_name setMarkerColorLocal "ColorBlack";
	_name setMarkerSizeLocal [0.5,0.5];
	_name setMarkerTextLocal _name;
} forEach d_target_names;
#endif

d_side_enemy = switch (d_enemy_side) do {
	case "EAST": {east};
	case "WEST": {west};
	case "GUER": {resistance};
};

d_side_player =
#ifdef __OWN_SIDE_EAST__
	east;
#endif
#ifdef __OWN_SIDE_WEST__
	west;
#endif
#ifdef __OWN_SIDE_GUER__
	resistance;
#endif
#ifdef __TT__
	west;
#endif

d_side_player_str =
#ifdef __OWN_SIDE_EAST__
	"east";
#endif
#ifdef __OWN_SIDE_WEST__
	"west";
#endif
#ifdef __OWN_SIDE_GUER__
	"guerrila";
#endif
#ifdef __TT__
	"west";
#endif

d_own_side_trigger =
#ifdef __OWN_SIDE_EAST__
	"EAST";
#endif
#ifdef __OWN_SIDE_WEST__
	"WEST";
#endif
#ifdef __OWN_SIDE_GUER__
	"GUER";
#endif
#ifdef __TT__
	"WEST";
#endif

d_ai_enemy_sides =
#ifdef __OWN_SIDE_EAST__
	[west];
#endif
#ifdef __OWN_SIDE_WEST__
	[east];
#endif
#ifdef __OWN_SIDE_GUER__
	[east];
#endif
#ifdef __TT__
	[east,west];
#endif

#ifndef __TT__
d_rep_truck = if (d_enemy_side == "EAST") then {"MtvrRepair"} else {"KamazRepair"};
#endif

d_version_string =
#ifdef __OWN_SIDE_EAST__
	"East";
#endif
#ifdef __OWN_SIDE_WEST__
	"West";
#endif
#ifdef __OWN_SIDE_GUER__
	"Guer";
#endif
#ifdef __TT__
	"Two Teams";
#endif

//default flag GUER
#ifdef __OWN_SIDE_WEST__
FLAG_BASE setflagtexture "pics\op4_small.paa";
#endif
#ifdef __OWN_SIDE_EAST__
FLAG_BASE setflagtexture "\ca\data\flag_rus_co.paa";
#endif

if (d_with_mgnest) then {
	d_mg_nest = 
#ifdef __OWN_SIDE_GUER__
	"GUE_WarfareBMGNest_PK";
#endif
#ifdef __OWN_SIDE_EAST__
	"RU_WarfareBMGNest_PK";
#endif
#ifdef __OWN_SIDE_WEST__
	"USMC_WarfareBMGNest_M240";
#endif
#ifdef __TT__
	"";
#endif
};

d_sm_bonus_vehicle_array = (
#ifdef __DEFAULT__
	switch (d_own_side) do {
		case "GUER": {["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1"]};
		case "WEST": {
			if (__ACEVer) then {
				["ACE_Stryker_MGS_Slat","ACE_Stryker_TOW_MG_SLAT","ACE_M113A3","ACE_Vulcan","ACE_Stryker_RV_SLAT","ACE_Stryker_ICV_M2_SLAT","ACE_M2A2_W","ACE_M6A1_W"]
			} else {
				["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1","AH64D"]
			}
		};
		case "EAST": {
			if (__ACEVer) then {
				["Su34","Ka52","Ka52Black","Mi24_P","Mi24_V","Su39","T72_RU","2S6M_Tunguska","T90"]
			} else {
				["Su34","Ka52","Ka52Black","Mi24_P","Mi24_V","Su39","T72_RU","2S6M_Tunguska","T90"]
			}
		};
	}
#endif
#ifdef __EVERON__
	switch (d_own_side) do {
		case "GUER": {["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1"]};
		case "WEST": {
			if (__ACEVer) then {
				["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1","AH64D"]
			} else {
				["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1" ,"AH64D"]
			}
		};
		case "EAST": {
			if (__ACEVer) then {
				["Su34","Ka52","Ka52Black","Mi24_P","Mi24_V","Su39","T72_RU","2S6M_Tunguska","T90"]
			} else {
				["Su34","Ka52","Ka52Black","Mi24_P","Mi24_V","Su39","T72_RU","2S6M_Tunguska","T90"]
			}
		};
	}
#endif
#ifdef __TT__
	[
		["A10","AH1Z","UH1Y","AV8B","AV8B2", "F35B", "M1A2_TUSK_MG","M1A1","AH64D"],
		["Su34","Ka52","Ka52Black","Mi24_P","Mi24_V","Su39","T72_RU","2S6M_Tunguska","T90"]
	]
#endif
);

d_mt_bonus_vehicle_array = (
#ifdef __DEFAULT__
	switch (d_own_side) do {
		case "GUER": {["BMP2_Gue","BRDM2_Gue","T34","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","HMMWV_Avenger"]};
		case "WEST": {
			if (__ACEVer) then {
				["AAV","LAV25","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","MLRS","HMMWV_Avenger","ACE_Stryker_ICV_M2_SLAT","ACE_Stryker_ICV_MK19_SLAT","ACE_Stryker_RV","ACE_M113A3","ACE_Vulcan","ACE_M2A2_W","ACE_M6A1_W"]
			} else {
				["AAV","LAV25","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","MLRS","HMMWV_Avenger"]
			}
		};
		case "EAST": {
			if (__ACEVer) then {
				["BMP3","BTR90","GAZ_Vodnik","GAZ_Vodnik_HMG","UAZ_AGS30_RU"]
			} else {
				["BMP3","BTR90","GAZ_Vodnik","GAZ_Vodnik_HMG","UAZ_AGS30_RU"]
			}
		};
	}
#endif
#ifdef __EVERON__
	switch (d_own_side) do {
		case "GUER": {["BMP2_Gue","BRDM2_Gue","T34","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","HMMWV_Avenger"]};
		case "WEST": {
			if (__ACEVer) then {
				["AAV","LAV25","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","MLRS","HMMWV_Avenger"]
			} else {
				["AAV","LAV25","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","MLRS","HMMWV_Avenger"]
			}
		};
		case "EAST": {
			if (__ACEVer) then {
				["BMP3","BTR90","GAZ_Vodnik","GAZ_Vodnik_HMG","UAZ_AGS30_RU"]
			} else {
				["BMP3","BTR90","GAZ_Vodnik","GAZ_Vodnik_HMG","UAZ_AGS30_RU"]
			}
		};
	}
#endif
#ifdef __TT__
	[
		["AAV","LAV25","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","MLRS","HMMWV_Avenger"],
		["BMP3","BTR90","GAZ_Vodnik","GAZ_Vodnik_HMG","UAZ_AGS30_RU"]
	]
#endif
);

// positions for aircraft factories (if one get's destroyed you're not able to service jets/service choppers/repair wrecks)
// first jet service, second chopper service, third wreck repair

d_aircraft_facs =
#ifdef __DEFAULT__
	[[[4101.0366,2223.0212,0],0],[[4388.9326,2239.8613,0],0],[[4699.9712,2239.8613,0],0]];
#endif
#ifdef __EVERON__
	[[[4814.13,11092.8,0],0],[[4841.15,11948,0],0],[[4814.62,11361.6,0],0]];
#endif
#ifdef __TT__
	[];
#endif

x_drop_array =
#ifdef __OWN_SIDE_GUER__
	[["Drop Artillery", "M119"], ["Drop Humvee","HMMWV"], ["Drop Ammo", "USBasicAmmunitionBox"]];
#endif
#ifdef __OWN_SIDE_WEST__
	if (__ACEVer) then {
		[["Drop Mortar", "M252"], ["Drop Humvee","ACE_HMMWV_GMV"], ["Drop Ammo", "ACE_USSpecialWeaponsBox"]]
	} else {
		[["Drop Artillery", "M119"], ["Drop Humvee","HMMWV"], ["Drop Ammo", "USBasicAmmunitionBox"]]
	};
#endif
#ifdef __OWN_SIDE_EAST__
	if (__ACEVer) then {
		[["Drop Artillery", "D30_RU"], ["Drop Uaz","UAZ_RU"], ["Drop Ammo", "RUBasicAmmunitionBox"]]
	} else {
		[["Drop Artillery", "D30_RU"], ["Drop Uaz","UAZ_RU"], ["Drop Ammo", "RUBasicAmmunitionBox"]]
	};
#endif
#ifdef __TT__
	[["Drop Artillery", "M119"], ["Drop Humvee","HMMWV"], ["Drop Ammo", "USBasicAmmunitionBox"]];
#endif

// side of the pilot that will fly the drop air vehicle
x_drop_side = d_own_side;

// these vehicles can be lifted by the wreck lift chopper (previous chopper 4), but only, if they are completely destroyed
#ifndef __TT__
x_heli_wreck_lift_types = d_sm_bonus_vehicle_array + d_mt_bonus_vehicle_array;
#else
x_heli_wreck_lift_types = (d_sm_bonus_vehicle_array select 0) + (d_sm_bonus_vehicle_array select 1) + (d_mt_bonus_vehicle_array select 0) + (d_mt_bonus_vehicle_array select 1);
#endif

d_next_jump_time = -1;

// d_jumpflag_vec = empty ("") means normal jump flags for HALO jump get created
// if you add a vehicle typename to d_jumpflag_vec (d_jumpflag_vec = "UAZ"; for example) only a vehicle gets created and no HALO jump is available
d_jumpflag_vec = "";

d_side_mission_winner = 0;
d_objectID1 = objNull;
d_objectID2 = objNull;

MEDIC_TENT1 allowDamage false;
#ifndef __CARRIER__
AMMOBUILDING allowDamage false;
#endif
MEDIC_TENT2 allowDamage false;
#ifndef __TT__
if (isNil "d_with_carrier") then {
	WALL1 allowDamage false;
	WALL2 allowDamage false;
	WALL3 allowDamage false;
};
#endif
#ifdef __TT__
AMMOBUILDING2 allowDamage false;
#endif

// for markers and revive (same like NORRN_player_units)
d_player_entities = if (!(__ACEVer)) then {
	["RESCUE","RESCUE2","alpha_1","alpha_2","alpha_3","alpha_4","alpha_5","alpha_6","alpha_7","alpha_8","bravo_1","bravo_2","bravo_3","bravo_4","bravo_5","bravo_6","bravo_7","bravo_8","charlie_1","charlie_2","charlie_3","charlie_4","charlie_5","charlie_6","charlie_7","charlie_8","delta_1","delta_2","delta_3","delta_4","delta_5","delta_6","echo_1","echo_2","echo_3","echo_4","echo_5","echo_6","echo_7","echo_8"]
} else {
	["RESCUE","RESCUE2","alpha_1","alpha_2","alpha_3","alpha_4","alpha_5","alpha_6","alpha_7","alpha_8","alpha_9","bravo_1","bravo_2","bravo_4","bravo_5","bravo_6","bravo_7","bravo_8","charlie_1","charlie_2","charlie_4","charlie_5","charlie_6","charlie_7","charlie_8","delta_1","delta_2","delta_3","delta_4","echo_1","echo_2","echo_4"]
};
if (!isDedicated) then {
d_player_roles = if (!(__ACEVer)) then {
	["PLT LD","PLT SGT","SL","SN","MG","AT","GL","CM","AR","AM","TL","OP","GL","MG","MM","CM","GL","DS","SL","SN","AR","AT","RM","CM","MG","AT","EN","EN","EN","EN","EN","EN","SL","SN","AR","AT","RM","CM","MG","AT"]
} else {
	["PLT LD","PLT SGT","SL","SN","MG","AT","GL","CM","AR","AM","TL","OP","MG","MM","CM","GL","DS","SL","SN","AR","AT","RM","CM","AT","EN","EN","EN","EN","EN","SL","SN","AT","RM","CM","MG","AT","PL","PL","PL","PL"]
};
};

// position base, a,b, for the enemy at base trigger and marker
d_base_array =
#ifdef __DEFAULT__
	if (isNil "d_with_carrier") then {[[4566.188,2208.4478,0], 550, 110, 0]} else {[[14716.3,542.458,0], 40,230,270]};
#endif
#ifdef __EVERON__
	if (isNil "d_with_carrier") then {[[4808.47,11443.2,0], 600, 140, 0]} else {[[14716.3,542.458,0], 40,230,270]};
#endif
#ifdef __TT__
	[
		[[4938.07,2427.23,0], 400, 100, 30], // West
		[[12105,12661.4,0], 400, 100, 20] // East
	];
#endif

if (AmmoBoxHandling) then {last_ammo_drop = -3423};

#ifdef __TT__
d_tt_points = [
	15, // points for the main target winner team
	7, // points if draw (main target)
	4, // points for destroying main target radio tower
	3, // points for main target mission
	10, // points for sidemission
	3, // points for capturing a camp (main target)
	2, // points that get subtracted when loosing a mt camp again
	4, // points for destroying a vehicle of the other team
	1 // points for killing a member of the other team
];
#endif
// position of radar and anti air at own base
#ifdef __DEFAULT__
d_base_radar_pos = [5000.1621,2239.7759,0];
d_base_anti_air1 = [4599.2173,2239.2529,0];
d_base_anti_air2 = [4050.915,2139.1443,0];
#endif
#ifdef __EVERON__
d_base_radar_pos = [4853.66,12051.6,0];
d_base_anti_air1 = [4694.31,11914.1,0];
d_base_anti_air2 = [4710.19,10933.5,0];
#endif